let { getResourceListTotalType, getResourceListTotalDepartment,getResourceListNumDepartment }= require ("../../../api/slibrary.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    project: [{
      text: '全部',
      id: 1,
      fontWeight: '600',
      color: '#409EFF'
    },
    {
      text: '投资拓展中心',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '科技中心',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '双创中心',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '深圳项目',
      id: 2,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '联健元和',
      id: 2,
      fontWeight: '600',
      color: '#666'
    },{
      text: '达博',
      id: 3,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '科澜项目',
      id: 4,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '国科项目',
      id: 5,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '江环项目',
      id: 6,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '创界项目',
      id: 7,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '秦淮项目',
      id: 8,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '黄埭项目',
      id: 9,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '花桥项目',
      id: 10,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '江宁项目',
      id: 11,
      fontWeight: '600',
      color: '#666'
    }, {
      text: '江北项目',
      id: 12,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '西山项目',
      id: 13,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '北联新翼',
      id: 14,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '新零售',
      id: 15,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '总裁办',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '运营服务中心',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    {
      text: '其他',
      id: 16,
      fontWeight: '600',
      color: '#666'
    },
    ],
    typeTotal: {
      cyjj: '',
      qtzy: '',
      xh: '',
      dyds: '',
      zfzy: '',
      fwjg: '',
      zdqy: ''
    },
    departmentTotal: [],
    params: {
      project: '全部'
    },
    departmentList:[]
  },
  onSelect(event) {
    let { index, text } = event.currentTarget.dataset;
    let tabs = this.data.project
    for (let i = 0; i < tabs.length; i++) {
      if (i === index) {
        tabs[i].color = '#409EFF';
      } else {
        tabs[i].color = '#666';
      }
    }
    this.setData({
      project: tabs,
      [`params.project`]: text
    });
    if (text !== '全部') {
      this.getNewResourceListNumDepartment()
    }
  },
  getNewResourceListTotalType() {
    getResourceListTotalType('全部类型').then(res => {
      this.setData({
        [`typeTotal.cyjj`]: (res.data.find(item => item.zylx == '产业基金')).tjs,
        [`typeTotal.qtzy`]: (res.data.find(item => item.zylx == '其他资源')).tjs,
        [`typeTotal.xh`]: (res.data.find(item => item.zylx == '协会/校友会')).tjs,
        [`typeTotal.dyds`]: (res.data.find(item => item.zylx == '大院大所')).tjs,
        [`typeTotal.zfzy`]: (res.data.find(item => item.zylx == '政府资源')).tjs,
        [`typeTotal.fwjg`]: (res.data.find(item => item.zylx == '服务机构')).tjs,
        [`typeTotal.zdqy`]: (res.data.find(item => item.zylx == '重点企业')).tjs,
      })
    })
  },
  getNewResourceListTotalDepartment() {
    getResourceListTotalDepartment('全部资源').then(res => {
      this.setData({
        departmentTotal: res.data
      })
    })
  },
  getNewResourceListNumDepartment(){
    getResourceListNumDepartment(this.data.params.project).then(res=>{
      this.setData({
        departmentList:res.data
      })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getNewResourceListTotalType()
    this.getNewResourceListTotalDepartment()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})